package com.example.demo.executor;

import com.example.demo.entity.ExecuteInformationEntity;
import com.example.demo.entity.RelatedExecuteInformationEntity;
import com.example.demo.exception.BizErrorCode;
import com.example.demo.exception.BizException;

import java.util.List;
import java.util.Map;

/**
 * @author 又菜又爱浪
 * @date 2021.12.29
 * 数据处理接口
 */
public interface Executor {

    /**
     * 主表数据处理
     * @param informationEntity 主表信息实体
     * @return
     */
    default boolean execute(ExecuteInformationEntity informationEntity){
        throw new BizException(BizErrorCode.NOT_SUPPORT_THIS_OPERATION);
    }

    /**
     * 关联表数据处理
     * @param executeConditions 与主表关联列的数据集合
     * @param relatedInformation  关联信息实体
     * @return
     */
    default boolean execute(List<Object> executeConditions, RelatedExecuteInformationEntity relatedInformation){
        throw new BizException(BizErrorCode.NOT_SUPPORT_THIS_OPERATION);
    }

    /**
     * 单次循环数据处理
     */
    default void singleCycleDataDeal(Map<String, List<Object>> params, String tableName, String primaryKey,
                                     String executeType, String backupDealType, List<RelatedExecuteInformationEntity> relatedInfos){
        throw new BizException(BizErrorCode.NOT_SUPPORT_THIS_OPERATION);
    }
}
